Early Preview

This is currently very much a preview. Please feel free to try things out, but don't be upset if anything is not yet working. Feedback is welcome over on our GitHub Dicussions page.

interface Microsoft.​Extensions.​Http.​ITypedHttpClientFactory<​TClient>

Assembly: Microsoft.Extensions.Http

A factory abstraction for a component that can create typed client instances with custom configuration for a given logical name.

Remarks

<para> The <see cref="T:Microsoft.Extensions.Http.ITypedHttpClientFactory`1" /> is infrastructure that supports the <see cref="M:Microsoft.Extensions.DependencyInjection.HttpClientFactoryServiceCollectionExtensions.AddHttpClient``1(Microsoft.Extensions.DependencyInjection.IServiceCollection,System.String)" /> and <see cref="M:Microsoft.Extensions.DependencyInjection.HttpClientBuilderExtensions.AddTypedClient``1(Microsoft.Extensions.DependencyInjection.IHttpClientBuilder)" /> functionality. This type should rarely be used directly in application code, use <see cref="M:System.IServiceProvider.GetService(System.Type)" /> instead to retrieve typed clients. </para> <para> A default <see cref="T:Microsoft.Extensions.Http.ITypedHttpClientFactory`1" /> can be registered in an <see cref="T:Microsoft.Extensions.DependencyInjection.IServiceCollection" /> by calling <see cref="M:Microsoft.Extensions.DependencyInjection.HttpClientFactoryServiceCollectionExtensions.AddHttpClient(Microsoft.Extensions.DependencyInjection.IServiceCollection)" />. The default <see cref="T:Microsoft.Extensions.Http.ITypedHttpClientFactory`1" /> will be registered in the service collection as a singleton open-generic service. </para> <para> The default <see cref="T:Microsoft.Extensions.Http.ITypedHttpClientFactory`1" /> uses type activation to create typed client instances. Typed client types are not retrieved directly from the <see cref="T:System.IServiceProvider" />. See <see cref="M:Microsoft.Extensions.DependencyInjection.ActivatorUtilities.CreateInstance(System.IServiceProvider,System.Type,System.Object[])" /> for details. </para>

Methods

TClient
CreateClient​(System.​Net.​Http.​HttpClient httpClient)
Creates a typed client given an associated <see cref="T:System.Net.Http.HttpClient" /> .
Returns An instance of <typeparamref name="TClient" /> .
httpClient An <see cref="T:System.Net.Http.HttpClient" /> created by the <see cref="T:System.Net.Http.IHttpClientFactory" /> for the named client associated with <typeparamref name="TClient" /> .